<?php function renderChildren($category, $view){ ?>
    <li><div style="text-align:right;" class=" <?php
            if ($view->module=='catalog' && $view->category_id==$category['id'] ):
            ?> ui-state-active <?php elseif( ! $category['active']):
            ?> ui-state-disabled <?php endif;
            ?> ui-corner-all">
        <a style="float:left;" href="<?php
        echo $view->url(array('module' => 'catalog',
                                  'controller'=>'category',
                                  'action'=>'admin',
                                  'category_id'=>$category['id']),
                'default', true)
                ?>">
                <span class="ui-corner-all ui-widget ui-icon ui-icon-folder-open "></span>
                <?php echo $category['title'] ; ?></a>
                (<?php echo $category['product_count'] ; ?>)
                
</div>  
        <?php if ($category->getNode()->hasChildren()): ?>
            <ul>
                <?php foreach ( $category->getNode()->getChildren() as $child ): ?>
                    <?php renderChildren($child, $view); ?>
                <?php endforeach;?>
            </ul>
        <?php endif; ?>
   </li>
<?php } ?>

<ul class="tree"><?php renderChildren($this->rootCategory, $this); ?></ul>